<?php 
if (!isset($_SESSION)) {
  session_start();
}
require_once('../Connections/mysql.php'); 
require_once('./functions/functions.php'); 
require_once('./classes/hero_class.php'); 
mysql_select_db($database_mysql, $mysql);
if (isset($_POST["name"]))
{
	$new_hero=new hero;
	$new_hero->create_new_hero($_POST['name'],$_SESSION['MM_UserID'],$_POST['description']);
	$new_hero->save_hero(); 
	$link_with_account="UPDATE users SET
	 charactor=$new_hero->id
	 WHERE id=$_SESSION[MM_UserID]";
	mysql_query($link_with_account,$mysql);
	$new_hero=NULL;
}
//再次验证
$sqlquery="SELECT
 id,charactor
FROM users WHERE 
id=$_SESSION[MM_UserID]";
$sql_result=mysql_query($sqlquery,$mysql);
if (mysql_result($sql_result,0,'charactor'))
{
	Header('Location:main.php');
}

?>

<meta charset="utf-8" />

<link href="../css/trow_game_classic.css" rel="stylesheet" type="text/css" />

<style type="text/css">
form {
	background-color: #CCC;
	margin: auto;
	width: 600px;
	text-align: center;
	vertical-align: middle;
}
</style>

<body>
<form action="./create_charactor.php" method="post">
人物名称：<br /><input name="name" type="text" /><br />
人物描述：<br /><textarea name="description" cols="" rows="5"></textarea><br />
<input type="submit" value="新建人物" />
</form>
</body>